<template>
  <div class="hmax sz ks-row">
    <leftModel
      :type="value.type"
      :modelId="value.modelId"
      :columns="value.configJson.columns"
      :isCreate="isCreate"
      @changeCheck="updateColumns"
    />
    <div class="ks-col ovh">
      <rightModel v-model="value" ref="rightModel" />
    </div>
  </div>
</template>
<script>
import leftModel from "./leftModel/index.vue";
import rightModel from "./rightModel/index.vue";
import { intersection } from "lodash";
export default {
  components: {
    leftModel,
    rightModel,
  },
  props: {
    value: {
      type: Object,
      default: () => {
        return {};
      },
    },
    isCreate: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {};
  },
  created() {},
  methods: {
    save() {
      return this.$refs.rightModel && this.$refs.rightModel.save();
    },
    handelGlobalConfig() {
      this.$refs.rightModel && this.$refs.rightModel.handelGlobalConfig();
    },
    //更新右侧数据
    updateColumns(list) {
      this.value.configJson.columns = list;
      if (
        this.value.configJson.duplicateCheckColumns &&
        this.value.configJson.duplicateCheckColumns.length
      ) {
        this.value.configJson.duplicateCheckColumns = intersection(
          this.value.configJson.duplicateCheckColumns,
          list.map((i) => i.code)
        );
      }
      this.$refs.rightModel?.computedCol();
    },
  },
};
</script>

<style lang="scss" scoped>
.hmax {
  height: 100%;
}
</style>
